package day_02.sort;

public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {10, 6, 5, 9, 8, 4, 3, 7, 1, 2};
        sort(arr);
        for (int value : arr) {
            System.out.print(value + " ");
        }
    }

    private static void sort(int[] arr){
        if(arr.length == 0 || arr.length == 1) return;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if(arr[j] > arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
    }
}
